
public class Server {
    
	private static final String crmip = "kazanmobile.student.iastate.edu";
    private static final String crmport = "31337";
    
	public static void main(String[] args)
	{
		Ice.Communicator communicator = null;

		try
		{
			//
			// Boilerplate code for starting up the Ice server.
			//
			Ice.Properties properties = Ice.Util.createProperties();
			properties.load("config_server");
			Ice.InitializationData id = new Ice.InitializationData();
			id.properties = properties;
			communicator = Ice.Util.initialize(id);

			// "IceHelloAdapter" refers to the line "IceHelloAdapter.Endpoints"
			// in the server configuration file loaded above
			Ice.ObjectAdapter adapter = communicator.createObjectAdapter("IceTrackingServiceAdapter");

			// TrackingServiceImpl implements the tracking service
			Ice.Object object = new TrackingServiceImpl();

			// Add the servant to the object adapter.
			// "trackingservice" is the the identity that the the client will use 
			// to find the remote OptimizationEngine object.
			adapter.add(object, Ice.Util.stringToIdentity("trackingservice"));

			// start accepting connections
			adapter.activate();
			System.out.println("Server listening...");
			
            ((TrackingServiceImpl) object).intializeCRM("CRM:tcp -h " + crmip + " -p " + crmport);
            System.out.println("CRM initialized");
			
			communicator.waitForShutdown();
		}
		catch (Ice.LocalException ex)
		{
			ex.printStackTrace();
			System.exit(1);
		}

		finally
		{
			//
			// Shut down the server, if it exists
			//
			if (communicator != null)
			{
				System.out.println("Server shutting down");
				try
				{
					communicator.destroy();
				}
				catch (Ice.LocalException ex)
				{
					ex.printStackTrace();
					System.exit(1);
				}
			}
		}
	}
}
